﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Device.Location;

namespace Rally_like_a_madman.Data
{
    [Table]
    public class Waypoint : INotifyPropertyChanged, INotifyPropertyChanging
    {
        public event PropertyChangingEventHandler PropertyChanging;
        public event PropertyChangedEventHandler PropertyChanged;
        
        private int idWaypointValue;
        private string nameValue;
        private double gpsLongitudeValue;
        private double gpsLatitudeValue;
        private string descriptionValue;

        [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
        public int IDWaypoint
        { 
            get 
            {
                return idWaypointValue; 
            } 
            private set 
            {
                NotifyPropertyChanging("IDWaypoint");
                idWaypointValue = value;
                NotifyPropertyChanged("IDWaypoint"); 
            }
        }
        [Column]
        public string Name
        {
            get
            {
                return nameValue;
            }
            set
            {
                NotifyPropertyChanging("Name");
                nameValue = value;
                NotifyPropertyChanged("Name");
            }
        }
        [Column]
        public double GPSLongitude 
        {   
            get
            {         
                return gpsLongitudeValue;    
            }  
            set 
            {
                NotifyPropertyChanging("GPSLongitude"); 
                gpsLongitudeValue = value;
                NotifyPropertyChanged("GPSLongitude");  
            }
        }
        [Column]
        public double GPSLatitude
        {
            get
            {
                return gpsLatitudeValue;
            }
            set
            {
                NotifyPropertyChanging("GPSLatitude");
                gpsLatitudeValue = value;
                NotifyPropertyChanged("GPSLatitude");
            }
        }
        [Column]
        public string Description
        {
            get
            {
                return descriptionValue;
            }
            set
            {
                NotifyPropertyChanging("Description");
                descriptionValue = value;
                NotifyPropertyChanged("Description");
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="propertyName"></param>
        private void NotifyPropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="propertyName"></param>
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Name;
        }
    }
}
